<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Nginx与Tomcat：深度对比分析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        
        .section-title {
            position: relative;
            display: inline-block;
            padding-bottom: 10px;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 60px;
            height: 3px;
            background: linear-gradient(90deg, #667eea, #764ba2);
            border-radius: 2px;
        }
        
        .feature-icon {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            padding: 20px;
            overflow-x: auto;
            font-family: 'Consolas', 'Monaco', monospace;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 30px 0;
        }
        
        .drop-cap {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .comparison-table {
            background: white;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        
        .comparison-table th {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-weight: 600;
            padding: 15px;
            text-align: left;
        }
        
        .comparison-table td {
            padding: 15px;
            border-bottom: 1px solid #e5e7eb;
        }
        
        .comparison-table tr:hover {
            background: #f9fafb;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6">
                    <i class="fas fa-server mr-4"></i>Nginx vs Tomcat
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">深度对比分析：选择最适合您的Web服务器</p>
                <div class="flex justify-center space-x-6">
                    <div class="bg-white bg-opacity-20 rounded-lg px-6 py-4">
                        <i class="fas fa-bolt text-3xl mb-2"></i>
                        <p class="font-semibold">高性能</p>
                    </div>
                    <div class="bg-white bg-opacity-20 rounded-lg px-6 py-4">
                        <i class="fas fa-shield-alt text-3xl mb-2"></i>
                        <p class="font-semibold">安全可靠</p>
                    </div>
                    <div class="bg-white bg-opacity-20 rounded-lg px-6 py-4">
                        <i class="fas fa-expand-arrows-alt text-3xl mb-2"></i>
                        <p class="font-semibold">可扩展</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction Section -->
    <section class="py-16 bg-white">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto">
                <h2 class="section-title text-3xl font-bold mb-8 text-gray-800">引言</h2>
                <p class="text-lg leading-relaxed text-gray-700 mb-6">
                    <span class="drop-cap">在</span>现代Web架构中，Nginx和Tomcat是两个极其重要的组件。作为Java程序员，深入理解这两个服务器的特性和差异，对于构建高性能、可扩展的Web应用至关重要。
                </p>
                <div class="grid md:grid-cols-2 gap-8 mt-10">
                    <div class="bg-gradient-to-br from-purple-50 to-indigo-50 p-8 rounded-xl card-hover">
                        <div class="flex items-center mb-4">
                            <i class="fas fa-nginx text-4xl feature-icon mr-4"></i>
                            <h3 class="text-2xl font-bold text-gray-800">Nginx</h3>
                        </div>
                        <p class="text-gray-700 leading-relaxed">
                            以其高效的反向代理和负载均衡功能而闻名，采用事件驱动模型和多进程架构，能够处理大量并发连接，非常适合高并发场景下的请求分发和静态资源处理。
                        </p>
                    </div>
                    <div class="bg-gradient-to-br from-orange-50 to-red-50 p-8 rounded-xl card-hover">
                        <div class="flex items-center mb-4">
                            <i class="fas fa-cat text-4xl feature-icon mr-4"></i>
                            <h3 class="text-2xl font-bold text-gray-800">Tomcat</h3>
                        </div>
                        <p class="text-gray-700 leading-relaxed">
                            广泛应用于Java Web应用开发和部署的Servlet容器，支持Servlet、JSP和多种Java EE规范，为开发者提供了丰富的功能来构建复杂的Web应用。
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Architecture Comparison -->
    <section class="py-16 bg-gray-50">
        <div class="container mx-auto px-6">
            <div class="max-w-6xl mx-auto">
                <h2 class="section-title text-3xl font-bold mb-12 text-gray-800">架构设计对比</h2>
                
                <div class="mermaid">
                    graph TB
                        subgraph Nginx架构
                            A[Master进程] --> B[Worker进程1]
                            A --> C[Worker进程2]
                            A --> D[Worker进程N]
                            B --> E[事件驱动]
                            C --> F[异步非阻塞]
                            D --> G[高并发处理]
                        end
                        
                        subgraph Tomcat架构
                            H[Catalina容器] --> I[连接器]
                            H --> J[引擎]
                            J --> K[Host虚拟主机]
                            K --> L[Context应用]
                            I --> M[线程池]
                            M --> N[请求处理线程]
                        end
                        
                        style A fill:#667eea,stroke:#fff,color:#fff
                        style H fill:#f97316,stroke:#fff,color:#fff
                </div>

                <div class="grid md:grid-cols-2 gap-8 mt-12">
                    <div class="bg-white p-8 rounded-xl shadow-lg">
                        <h3 class="text-2xl font-bold mb-6 text-purple-700">
                            <i class="fas fa-cube mr-2"></i>Nginx设计理念
                        </h3>
                        <ul class="space-y-4">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                <div>
                                    <strong class="text-gray-800">高性能与高并发：</strong>
                                    <span class="text-gray-600">采用事件驱动和异步非阻塞模型，通过epoll、kqueue等机制处理大量并发连接</span>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                                <div>
                                    <strong class="text-gray-800">轻量级与模块化：</strong>
                                    <span class="text-gray-600">核心轻量，通过模块扩展功能，易于定制和维护</span>
                                </div>
                            </li>
                        </ul>
                    </div>
                    
                    <div class="bg-white p-8 rounded-xl shadow-lg">
                        <h3 class="text-2xl font-bold mb-6 text-orange-700">
                            <i class="fas fa-cube mr-2"></i>Tomcat设计理念
                        </h3>
                        <ul class="space-y-4">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-orange-600 mt-1 mr-3"></i>
                                <div>
                                    <strong class="text-gray-800">Java EE应用支持：</strong>
                                    <span class="text-gray-600">提供可靠的Servlet容器，支持Servlet、JSP和WebSocket等规范</span>
                                </div>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-orange-600 mt-1 mr-3"></i>
                                <div>
                                    <strong class="text-gray-800">灵活性与可扩展性：</strong>
                                    <span class="text-gray-600">通过Valve、Filter和Listener等组件实现复杂功能需求</span>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Core Features Comparison -->
    <section class="py-16 bg-white">
        <div class="container mx-auto px-6">
            <div class="max-w-6xl mx-auto">
                <h2 class="section-title text-3xl font-bold mb-12 text-gray-800">核心功能对比</h2>
                
                <div class="comparison-table">
                    <table class="w-full">
                        <thead>
                            <tr>
                                <th class="w-1/3">功能特性</th>
                                <th class="w-1/3">Nginx</th>
                                <th class="w-1/3">Tomcat</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td class="font-semibold">反向代理</td>
                                <td><i class="fas fa-check-circle text-green-500 mr-2"></i>原生支持，性能卓越</td>
                                <td><i class="fas fa-times-circle text-red-500 mr-2"></i>需要额外配置</td>
                            </tr>
                            <tr>
                                <td class="font-semibold">负载均衡</td>
                                <td><i class="fas fa-check-circle text-green-500 mr-2"></i>多种算法，配置灵活</td>
                                <td><i class="fas fa-exclamation-circle text-yellow-500 mr-2"></i>需要集群配置</td>
                            </tr>
                            <tr>
                                <td class="font-semibold">静态资源处理</td>
                                <td><i class="fas fa-check-circle text-green-500 mr-2"></i>极高性能</td>
                                <td><i class="fas fa-exclamation-circle text-yellow-500 mr-2"></i>性能一般</td>
                            </tr>
                            <tr>
                                <td class="font-semibold">动态内容处理</td>
                                <td><i class="fas fa-times-circle text-red-500 mr-2"></i>需要代理到应用服务器</td>
                                <td><i class="fas fa-check-circle text-green-500 mr-2"></i>原生支持Java应用</td>
                            </tr>
                            <tr>
                                <td class="font-semibold">缓存机制</td>
                                <td><i class="fas fa-check-circle text-green-500 mr-2"></i>强大的缓存功能</td>
                                <td><i class="fas fa-exclamation-circle text-yellow-500 mr-2"></i>依赖第三方方案</td>
                            </tr>
                        </tbody>
                    </table>
                </div>

                <div class="grid md:grid-cols-3 gap-6 mt-12">
                    <div class="bg-gradient-to-br from-blue-50 to-indigo-50 